﻿Public Class TagIndex
#Region "Status Messages"
    Public Delegate Sub MessageEventHandler(message As String)
    Public Event StatusMessage As MessageEventHandler
    Protected Sub OnMessage(e As String)
        RaiseEvent StatusMessage(e)
    End Sub
#End Region

    Dim _tags As List(Of TagIndexInstance)
    Sub New()
        _tags = New List(Of TagIndexInstance)
    End Sub
    Public Function GetDependencyTag(filename As String) As HaloTag
        filename = filename.Substring(appSettings.XboxTagFolder.Length)
        Return GetDependencyTag(filename.Substring(0, filename.LastIndexOf(".")), "scnr")
    End Function
    Public Function GetDependencyTag(name As String, fourCC As String) As HaloTag
        For Each t As TagIndexInstance In _tags
            If t.Name = name And t.Type = fourCC Then
                Return t.Tag
            End If
        Next

        Dim instance As New TagIndexInstance()

        instance.ID = ((_tags.Count * &H10001) + &HE1740000)
        instance.Type = fourCC
        instance.Name = name
        _tags.Add(instance)
        instance.Tag = HaloTag.FromTagFile(name, fourCC, Me)
        Return instance.Tag
    End Function
    Private Class TagIndexInstance
        Public Tag As HaloTag
        Public Name As String
        Public Type As String
        Public ID As Integer
    End Class
End Class
